package cn.gwm.utils;

import cn.gwm.flink.streaming.constant.DefaultConstant;
import org.apache.flink.api.java.utils.ParameterTool;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @Author: liangguang
 * @Date: 2022/8/12
 * @Description:
 */
public class ProConfigUtil {

    public static Properties configPro(String fileName) {
        InputStream inputStream = ProConfigUtil.class.getClassLoader().getResourceAsStream(fileName);
        Properties props = new Properties();
        try {
            props.load(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return props;
    }

    public static Properties init() {
        String suffix = System.getenv().get(DefaultConstant.BOOT_PROFILES_ACTIVE);
        if (suffix == null) {
            suffix = "dev";
        }
        Properties properties = configPro("conf-" + suffix + ".properties");
        return properties;
    }


}
